import os
from langchain_community.chat_models import ChatZhipuAI 
from langchain.callbacks.streaming_stdout import (
    StreamingStdOutCallbackHandler
)
from dotenv import load_dotenv, find_dotenv

_ = load_dotenv(find_dotenv())
model = os.environ.get('model')
if model is None:
    raise ValueError("model is not set in the .env file")
 
llm = ChatZhipuAI(
    streaming=True, 
    callbacks=[StreamingStdOutCallbackHandler()], 
    temperature=0.9)
llm.invoke("写一篇关于花前月下的散文。")
